<template>
	<view class="container">
		<!-- <uni-data-picker placeholder="请选择地址" popup-title="请选择城市" collection="opendb-city-china" field="code as value, name as text" orderby="value asc" :step-searh="true" :self-field="code" parent-field="parent_code"
			@change="onchange" @nodeclick="onnodeclick">
		</uni-data-picker> -->
		<form @submit="formSubmit" @reset="formReset">
	
			<block v-for="(item,index) in shippingParam" :key="index" v-if="shippingType == 3">
				<!-- <tui-list-cell :hover="false" :arrow="true" @tap="openAddress"  v-if="shippingTitle== '' && item.key == 'address'  && item.field == 1"> -->
				<tui-list-cell :hover="false" :arrow="true" @click="details('./addresslist')" v-if="shippingTitle== '' && item.key == 'address'  && item.field == 1">
					<view class="tui-line-cell">
						<view class="tui-title">{{item.name}} <text class="red" v-if="item.type == 'must'">*</text></view>
					</view>
				</tui-list-cell>
				
				<!-- <tui-list-cell :arrow="true" :hover="false" v-if="shippingTitle != ''  && item.key == 'address' && item.field == 1"  @tap="openAddress"> -->
				<tui-list-cell :arrow="true" :hover="false" v-if="shippingTitle != ''  && item.key == 'address' && item.field == 1" @click="details('./addresslist')">
					<view class="tui-line-cell">
						<view class="tui-land-box">
							<!-- <tui-icon name="gps" size="20" color="#0A8FE2"></tui-icon> -->
							<image  class="gps" src="../../static/my/map.png"></image>
							<view class="tui-land-item">
								<span class="tui-land-content">收货人：{{shippingTitle}}，{{shippingMobile}}</span>
								<view class="tui-land-content">{{shippingProvince}} {{shippingCity}} {{shippingDistrict}} {{shippingAddress}}</view>
							</view>
						</view>
					</view>
				</tui-list-cell>
			
				<tui-list-cell :hover="false" :arrow="false" v-if="item.field == 0">
					<view class="tui-line-cell">
						<view class="tui-title">{{item.name}} <text class="red" v-if="item.type == 'must'">*</text></view>
						<input placeholder-class="phcolor" class="tui-input" :name="item.key" :placeholder="'请输入'+item.name" maxlength="150" type="text" v-model="item.val" />
					</view>
				</tui-list-cell>
			</block>
			
			<view class="case_box">
				<tui-card :title="{text: '已选商品'}">
					<template v-slot:body>
						<view class="case_box_des">
							<view class="case_content" v-for="(item,index) in goodsCart" :key="index">
								<view class="case_box_left">
									<view class="case_box_left_title">{{item.goods_name}}</view>
									<view class="case_box_left_des">￥{{formatPrice(item.goodsPrice)}}  / {{item.goods_attr}}</view>
								</view>
								<view class="case_box_right">
									+{{item.goodsNum}}
								</view>
							</view>	
						</view>
					</template>
					<template v-slot:footer>
						
						<view v-if="yuan_sumGoods" class="foot_content">
							共{{goodsCart.length}}件商品  合计 <text class="price">￥{{yuan_sumGoods}}</text><text style="margin-left: 10rpx;" class="price" v-if="freightAmount > 0">+ {{tui.centsToYuan(freightAmount)}}</text><text v-if="freightAmount > 0">运费</text>
						</view>
						<view v-else class="foot_content">
							共{{goodsCart.length}}件商品  合计 <text class="price">￥{{sumGoods}}</text><text style="margin-left: 10rpx;" class="price" v-if="freightAmount > 0">+ {{tui.centsToYuan(freightAmount)}}</text><text v-if="freightAmount > 0">运费</text>
						</view>
						<view v-if="specialoffer" class="foot_content">
							满减优惠: <text class="price" style="margin-left: 10rpx;">-￥{{specialoffer}} </text>
						</view>
					</template>
				</tui-card>
			</view>
			<tui-list-cell :hover="false">
				<view class="tui-line-cell">
					<view class="tui-title">备注</view>
					<input placeholder-class="phcolor" class="tui-input" name="remark" placeholder="请填写备注信息" maxlength="150" type="text" />
				</view>
			</tui-list-cell>
			<view class="tui-operation">
				<button class="btn-primary" hover-class="btn-hover" formType="submit" type="primary">立即支付 ￥{{tui.centsToYuan(Number(freightAmount)) + Number(sumGoods)}}</button>	
			</view>
		</form>
		<view class="tui-safearea-bottom"></view>
		<!--toast提示-->
		<tui-toast ref="toast"></tui-toast>
		<!--toast提示-->
		<!-- 支付弹窗 -->
		<tui-modal :show="modal" @click="payment" @cancel="hide" title="安全提示" content="付款后资金将进入对方帐户,请核实对方身份后支付。" :button="button"></tui-modal>
		<!-- 支付弹窗 -->
	</view>
</template>
<script>
	// const form = require("../../components/utils/formValidation.js")
	const util = require('../../utils/util.js');
	import tuiListCell from "@/components/list-cell/list-cell"
	import tuiListView from "@/components/list-view/list-view"
	import tuiCard from "@/components/card/card"
	import tuiToast from "@/components/extend/toast/toast"
	import tuiTag from "@/components/tag/tag"
	import tuiBadge from "@/components/badge/badge"
	import tuiIcon from "@/components/icon/icon"
	import tuiModal from "@/components/modal/modal"
	
	export default {
		components: {
			tuiListCell,
			tuiListView,
			tuiCard,
			tuiToast,
			tuiIcon,
			tuiTag,
			tuiBadge,
			tuiModal
		},
		data() {
			return {
				button: [{
					text: "确定",
					type: 'red'
				}],
				payParm: {},
				modal: false,
				goodsCart: [],
				sumGoods: 0,
				shippingParam: [],
				networkList: [],
				parm:{},
				shippingType: 3,
				shippingTitle: '',
				shippingAddress: '',
				shippingProvince: '',
				shippingCity: '',
				shippingDistrict: '',
				shippingMobile:'',
				orderinformation: '',
				reduction_config: '',
				specialoffer: '',
				yuan_sumGoods: '',
				goodsNumber: '0',
				jielongDetail: {},
				// 运费
				freightAmount: '0',
			}
		},
		onLoad: function(option){
			
			this.parm = option;
			console.log('parm',this.parm);
			this.goodsCart = uni.getStorageSync(this.tui.goodsPrefix() + option.jielong_id);
			this.goodsSum();
			
			for(let l = 0; l < this.goodsCart.length; l++){
				this.goodsNumber = Number(this.goodsNumber) + Number(this.goodsCart[l].goodsNum);
			}
			console.log('goodsCart',this.goodsCart,this.goodsCart.length);
			if(uni.getStorageSync('shippingParam'+ option.jielong_id)){
				this.shippingParam =  uni.getStorageSync('shippingParam'+ option.jielong_id);
				
			}
			this.networkList = uni.getStorageSync('networkList'+ option.jielong_id);
			console.log('shippingParam',this.shippingParam);
			for(let i = 0; i < this.shippingParam.length; i++){
				this.shippingParam[i]['val'] = '';
			}
			console.log('networkList',this.networkList);
			wx.hideShareMenu();
			console.log('cache_xaddress',wx.getStorageSync('cache_xaddress'));
			if (wx.getStorageSync('cache_xaddress').code) {
				console.log(wx.getStorageSync('cache_xaddress'));
				for(let i = 0; i < this.shippingParam.length; i++){
					if(this.shippingParam[i]['key'] == 'name'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').name;
					}
					if(this.shippingParam[i]['key'] == 'mobile'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').mobile;
					}
					if(this.shippingParam[i]['key'] == 'province'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').province;
					}
					if(this.shippingParam[i]['key'] == 'city'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').city;
					}
					if(this.shippingParam[i]['key'] == 'district'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').region;
					}
					if(this.shippingParam[i]['key'] == 'address'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').address;
					}
				}
				
				this.shippingTitle 		= wx.getStorageSync('cache_xaddress').name;
				this.shippingMobile 	= wx.getStorageSync('cache_xaddress').mobile;
				this.shippingProvince 	= wx.getStorageSync('cache_xaddress').province;
				this.shippingCity 		= wx.getStorageSync('cache_xaddress').city;
				this.shippingDistrict 	= wx.getStorageSync('cache_xaddress').region;
				this.shippingAddress 	= wx.getStorageSync('cache_xaddress').address;
				if(wx.getStorageSync('cache_xaddress').code){
					this.loadData(this.parm.jielong_id,this.parm.jielong_user_id);
				}
			}else if(wx.getStorageSync('mobile_putong')){
				for(let i = 0; i < this.shippingParam.length; i++){
					if(this.shippingParam[i]['key'] == 'mobile'){
						this.shippingParam[i]['val'] = wx.getStorageSync('mobile_putong');
					}
				}
			}
			
			
			
			console.log(this.parm);
			
			if(this.parm.shipping_type == '3'){
				this.orderinformation  = '-rWlOKR7dgNg_OApjqoxWs0rByZ00H3WoXU67gvBZr0';
			}else{
				this.orderinformation  = 'C7uRMkrhxNcH03vngMjOrTXZhoBzvrBdBPPKaGU4ltg';
			}
			
			this.reduction_config = uni.getStorageSync('reduction_config'+ option.jielong_id);
			console.log(this.reduction_config);
			if(this.sumGoods >= this.tui.centsToYuan(this.reduction_config.order_amount_min)){
				if(uni.getStorageSync('specialoffer'+ option.jielong_id) > 0){
					console.log(uni.getStorageSync('specialoffer'+ option.jielong_id));
					this.specialoffer = this.fomatFloat((this.sumGoods * uni.getStorageSync('specialoffer'+ option.jielong_id)) / 100000);
					if(this.tui.centsToYuan(this.reduction_config.max_amount) < this.specialoffer){
						this.specialoffer = this.tui.centsToYuan(this.reduction_config.max_amount);
					}
					console.log(this.sumGoods);
					this.yuan_sumGoods = this.sumGoods;
					this.sumGoods = this.tui.centsToYuan(this.tui.yuanToCents(Number(this.sumGoods)) - this.tui.yuanToCents(Number(this.specialoffer)));
					
					console.log(this.specialoffer);
				}
			}
		},
		onShow: function(){
			console.log('cache_xaddress',wx.getStorageSync('cache_xaddress'));
			if (wx.getStorageSync('cache_xaddress').code) {
				console.log(wx.getStorageSync('cache_xaddress'));
				for(let i = 0; i < this.shippingParam.length; i++){
					if(this.shippingParam[i]['key'] == 'name'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').name;
					}
					if(this.shippingParam[i]['key'] == 'mobile'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').mobile;
					}
					if(this.shippingParam[i]['key'] == 'province'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').province;
					}
					if(this.shippingParam[i]['key'] == 'city'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').city;
					}
					if(this.shippingParam[i]['key'] == 'district'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').region;
					}
					if(this.shippingParam[i]['key'] == 'address'){
						this.shippingParam[i]['val'] = wx.getStorageSync('cache_xaddress').address;
					}
				}
				
				this.shippingTitle 		= wx.getStorageSync('cache_xaddress').name;
				this.shippingMobile 	= wx.getStorageSync('cache_xaddress').mobile;
				this.shippingProvince 	= wx.getStorageSync('cache_xaddress').province;
				this.shippingCity 		= wx.getStorageSync('cache_xaddress').city;
				this.shippingDistrict 	= wx.getStorageSync('cache_xaddress').region;
				this.shippingAddress 	= wx.getStorageSync('cache_xaddress').address;
				if(wx.getStorageSync('cache_xaddress').code){
					this.loadData(this.parm.jielong_id,this.parm.jielong_user_id);
				}
			}else if(wx.getStorageSync('mobile_putong')){
				for(let i = 0; i < this.shippingParam.length; i++){
					if(this.shippingParam[i]['key'] == 'mobile'){
						this.shippingParam[i]['val'] = wx.getStorageSync('mobile_putong');
					}
				}
			}
		},
		methods: {
			details: function(url,type) {
				if(!url){
					return false
				}else{
					uni.navigateTo({
					   url: url,
					});
				}
			},
			onchange(e) {
				const value = e.detail.value
			},
			onnodeclick(node) {
				
			},
			loadData: function(jielong_id,jielong_user_id){
				console.log('code',wx.getStorageSync('cache_xaddress').code);
				var code = wx.getStorageSync('cache_xaddress').code;
				var than = this;
				than.tui.request('jielong/detail',{
					jielong_id: jielong_id,
					jielong_user_id: jielong_user_id,
					id: jielong_id,
				}).then((res) => {
					console.log('这是会眨巴',res)
					if(res.code == '0000'){
						than.jielongDetail = res;
						console.log('jielongDetail',than.jielongDetail);
						than.Calculate_the_freight(than.jielongDetail,code,than.goodsNumber);
					}else{
						let params = {
							title: res.msg,
							imgUrl: "/static/toast/fail-circle.png",
							icon: true
						};
						than.$refs.toast.show(params);
					}
				}).catch((err) => {
					let params = {
						title: "服务器异常",
						imgUrl: "/static/toast/fail-circle.png",
						icon: true
					};
					than.$refs.toast.show(params);
				})
			},
			fomatFloat: function(num){
			    num = num.toFixed(3);
			    num = num.substr(0,num.length-1);
			    // var lastStr = num.charAt(num.length-1);
			    if(num - 0.01 <= 0){
			        return num;
			    }else{
			        return (num - 0.01).toFixed(2);
			    }            
			},
			// 整合方法
			alwaysjudge: function(etyope){
				var thal = this;
				var etyope = etyope;
				// if(thal.estimate() == true){
				// 	setTimeout(function() {
				// 		// uni.redirectTo({
				// 		// 	url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
				// 		// });
				// 		getApp().globalData.Successfulorder = 1;
				// 		wx.navigateBack({
				// 		  url: '/pages/dragon/details?pay=1&id=' + thal.parm.jielong_id
				// 		})
				// 	}, 2000);
				// }else{
					thal.sendMsg(etyope);
				// }
				
			},
			// 是否已订阅
			estimate:function(){
				//判断是否已经订阅
				var thal = this;
				wx.getSetting({
					withSubscriptions : true,
					success(res) {
						console.log(res);
						if(res.subscriptionsSetting){
							let itemSettings = res.subscriptionsSetting.itemSettings;
							if (itemSettings.hasOwnProperty(thal.orderinformation)) {
								if (itemSettings[thal.orderinformation] == 'accept') {
									return true;
								}else{
									return false;
								}
							}else{
								return false;
							}
						}else{
							return false;
						}
					}
				})
			},
			// 订单发货订阅消息
			sendMsg:function(etyope){
			    var thal = this;
				var etyope = etyope;
			    wx.requestSubscribeMessage({
			      tmplIds: [thal.orderinformation],
			      success(res) {
			        console.log(res)
			        if (res[thal.orderinformation] == 'accept') {
						setTimeout(function() {
							// uni.redirectTo({
							// 	url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
							// });
							getApp().globalData.Successfulorder = 1;
							wx.navigateBack({
							  url: '/pages/dragon/details?pay=1&id=' + thal.parm.jielong_id
							})
						}, 2000);
			        }else{
						setTimeout(function() {
							// uni.redirectTo({
							// 	url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
							// });
							getApp().globalData.Successfulorder = 1;
							wx.navigateBack({
							  url: '/pages/dragon/details?pay=1&id=' + thal.parm.jielong_id
							})
						}, 2000);
					}
			      },
			      fail(err) {
			        //失败
					setTimeout(function() {
						// uni.redirectTo({
						// 	url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
						// });
						getApp().globalData.Successfulorder = 1;
						wx.navigateBack({
						  url: '/pages/dragon/details?pay=1&id=' + thal.parm.jielong_id
						})
					}, 2000);
			        console.error(err);
			      }
			    });
			},
			hide: function(){
				this.modal = false
			},
			openAddress: function(){
				let that = this;
				wx.getSetting({
				  success(res) {
					console.log(res);
					if (res.authSetting['scope.address'] == false) {
					  wx.openSetting({
						  
					  })
					}else{
					  //打开选择地址
					  wx.chooseAddress({
					    success (res) {
							console.log('地址信息',res);
							if(that.tui.addressfiltering(res.nationalCode,res.countyName) == false){
								let params = {
									title: '地址有误，请重新添加',
									imgUrl: "/static/toast/fail-circle.png",
									icon: true
								};
								that.$refs.toast.show(params);
								return false;
							}
							
							let Title = '', Mobile='', Province = '', City = '', District = '', Address = '';
							for(let i = 0; i < that.shippingParam.length; i++){
								if(that.shippingParam[i]['key'] == 'name'){
									that.shippingParam[i]['val'] = res.userName;
									Title += res.userName;
								}
								if(that.shippingParam[i]['key'] == 'mobile'){
									that.shippingParam[i]['val'] = res.telNumber;
									Mobile = res.telNumber;
								}
								if(that.shippingParam[i]['key'] == 'province'){
									that.shippingParam[i]['val'] = res.provinceName;
									Province = that.shippingParam[i]['val'];
								}
								if(that.shippingParam[i]['key'] == 'city'){
									that.shippingParam[i]['val'] = res.cityName;
									City = that.shippingParam[i]['val'];
								}
								if(that.shippingParam[i]['key'] == 'district'){
									that.shippingParam[i]['val'] = res.countyName;
									District = that.shippingParam[i]['val'];
								}
								if(that.shippingParam[i]['key'] == 'address'){
									that.shippingParam[i]['val'] = res.detailInfo;
									Address = that.shippingParam[i]['val'];
								}
							}
							that.shippingTitle = Title;
							that.shippingMobile = Mobile;
							that.shippingProvince = Province;
							that.shippingCity = City;
							that.shippingDistrict = District;
							that.shippingAddress = Address;postalCode
							
							//缓存收货信息
							wx.setStorage({
							   key: 'cache_xaddress',
							   data: res
							});
							that.Calculate_the_freight(that.jielongDetail,res.postalCode,that.goodsNumber);
						}
					  })
					}
				  },
				  fail(res){
					console.log('调用失败')
				  }
				})
			},
			payment: function(e){
				
				console.log('eee pay',e)
				let that = this;
				if(e.index == 0){
					// console.log('typeof',typeof(this.payParm.goods_list))
					if(this.payParm.goods_list){
						this.payParm.goods_list = JSON.stringify(this.payParm.goods_list);
					}
					// console.log('typeof',typeof(this.payParm.shipping_param))
					if(this.payParm.shipping_param){
						this.payParm.shipping_param = JSON.stringify(this.payParm.shipping_param);
					}
					
					if(this.specialoffer){
						this.payParm.reduction_amount = this.tui.yuanToCents(this.specialoffer);
						console.log('payParm',this.payParm);
					}
					if(this.parm.jielong_user_id){
						this.payParm.jielong_user_id = this.parm.jielong_user_id;
					}
					// this.payParm.channel_code = '1011';
					console.log('payParm_add',this.payParm);
					// this.payParm.channel_code = 1006;
					that.tui.request('order/add',this.payParm).then((res) => {
						getApp().globalData.Successfulorder = 2;
						uni.removeStorageSync(this.tui.goodsPrefix() + that.parm.jielong_id);
						uni.removeStorageSync('shippingParam'+ that.parm.jielong_id)
						this.modal = false
						if(res.code == '0000'){
							console.log(res.payInfo);
							uni.requestPayment({
								provider: 'wxpay',
								timeStamp: res.payInfo.timeStamp,
								nonceStr: res.payInfo.nonceStr,
								package: res.payInfo.package,
								signType: res.payInfo.signType,
								paySign: res.payInfo.paySign,
								success: function (res) {
									console.log(res);
									if(res.errMsg == 'requestPayment:ok'){
										let params = {
											title: '支付成功',
											imgUrl: "/static/toast/check-circle.png",
											icon: true
										};
										that.$refs.toast.show(params);
										setTimeout(function() {
											getApp().globalData.Successfulorder = 1;
											wx.navigateBack({
											  url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
											})
										}, 2000);
										// if(typeof wx.requestSubscribeMessage === 'function'){
										// 	that.alwaysjudge();
										// }else{
										// 	wx.showModal({
										// 		title: '提示！',
										// 		content: '微信版本过低，订阅功能无法使用哦！',
										// 		success(res_versions) {
										// 			if (res_versions.confirm) {
										// 				setTimeout(function() {
										// 					getApp().globalData.Successfulorder = 1;
										// 					wx.navigateBack({
										// 					  url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
										// 					})
										// 				}, 2000);
										// 			} else if (res_versions.cancel) {
										// 				setTimeout(function() {
										// 					getApp().globalData.Successfulorder = 1;
										// 					wx.navigateBack({
										// 					  url: '/pages/dragon/details?pay=1&id=' + that.parm.jielong_id
										// 					})
										// 				}, 2000);
										// 			}
										// 		}
										// 	})
										// }
										
									}else{
										setTimeout(function() {
											uni.navigateTo({
												url: '/pages/my/order'
											});
										}, 2000);
									}
								
								},
								fail: function (err) {
									console.log(err);
									// payClose   order_id
									that.orderCancel()
									let params = {
										title: '支付失败',
										imgUrl: "/static/toast/fail-circle.png",
										icon: true
									};
									that.$refs.toast.show(params);
								}
							});
						}else{
							let params = {
								title: res.msg,
								imgUrl: "/static/toast/fail-circle.png",
								icon: true
							};
							that.$refs.toast.show(params);
						}
					}).catch((err) => {
						let params = {
							title: "服务器异常",
							imgUrl: "/static/toast/fail-circle.png",
							icon: true
						};
						that.$refs.toast.show(params);
					})
				}
			},
			formSubmit: function(e) {
				let formData = e.detail.value;
				let goods = []
				let status = 1
				let that = this;
				console.log('这是什么参数据',that.shippingParam);
				let array = [];
				var sum = 0;
				for(let i = 0; i < that.shippingParam.length; i++){
					if(that.shippingParam[i]['val'] == '' && that.shippingParam[i]['type'] == 'must' ){
						let params = {
							title: '请填写'+that.shippingParam[i]['name'] ,
							imgUrl: "/static/toast/info-circle.png",
							icon: true
						};
						that.$refs.toast.show(params);
						status = 0
						break;
					}
					if(that.shippingParam[i]['key'] == 'mobile' && util.isMobile(that.shippingParam[i]['val']) == false && that.shippingType != 3){		 
						let params = {
							title: '手机号不正确',
							imgUrl: "/static/toast/info-circle.png",
							icon: true
						};
						that.$refs.toast.show(params);
						status = 0						
						break;
					}
					if(that.shippingParam[i]['key'] == 'mobile' && this.parm.shipping_type != '3'){
						wx.setStorage({
						   key: 'mobile_putong',
						   data: that.shippingParam[i]['val']
						});
						console.log('手机号码',that.shippingParam[i]['val']);
					}
					// if(that.shippingType == 2){
					// 	if(that.shippingParam[i]['key'] == "shipping_network_title" || that.shippingParam[i]['key'] == "shipping_network_address" || that.shippingParam[i]['key'] == "shipping_network_name" || that.shippingParam[i]['key'] == "shipping_network_phone"){
							
					// 	}else{
					// 		console.log(sum);
					// 		array[sum] = that.shippingParam[i];
					// 		sum = sum + 1;
					// 	}
					// }
					console.log('这是什么val', that.shippingParam[i]['key'],that.shippingParam[i]['val']);
				}
				// return false;
				if(status != 1){
					return false
				}
				that.payParm.jielong_id = that.parm.jielong_id;
				that.payParm.pay_open = that.payOpen;
				that.payParm.remark = formData.remark;
				for(let i = 0; i < that.goodsCart.length; i++){
					goods.push({goods_id:that.goodsCart[i]['goods_id'],goods_number:that.goodsCart[i]['goodsNum']})  
				}
				that.payParm.goods_list = goods;
				
				that.payParm.shipping_param = {
					name: that.shippingTitle,
					mobile: that.shippingMobile,
					area_name: that.shippingProvince + that.shippingCity + that.shippingDistrict,
					address: that.shippingAddress,
					area: wx.getStorageSync('cache_xaddress').code,
				};
				
				console.log('shipping_param',that.payParm.shipping_param);
				// return false;
				if(that.payOpen == 1){
					that.modal = true;
				}else{
					var arrays = {
						index:0
					};
					that.payment(arrays);
				}
			},
			orderCancel: function(){
				let that = this;
				that.loadding = true
				that.tui.request('order/payClose',{order_id : that.parm.jielong_id}).then((res) => {
					console.log(res)
					
				}).catch((err) => {
					let params = {
						title: "服务器异常",
						imgUrl: "/static/toast/fail-circle.png",
						icon: true
					};
					that.$refs.toast.show(params);
				})
				
			},
			formatPrice: function(fee){
				return this.tui.centsToYuan(fee)
			},
			goodsSum: function(){
				if(this.goodsCart.length == 0){
					this.sumGoods = 0;
					return false;
				}
				let sum = 0
				console.log('获取总订单数据',this.goodsCart);
				for(let i = 0; i < this.goodsCart.length; i++){
					sum =  sum + (this.goodsCart[i]['goodsPrice'] * this.goodsCart[i]['goodsNum'])
				}
				this.sumGoods = this.tui.centsToYuan(sum);
			},
			/**
			 * 获取运费
			 *
			 * @param array jielongInfo		接龙信息
			 * @param array area_code		地区CODE
			 * @param array goodsCount		订单商品数量
			*/
			Calculate_the_freight: function(jielongInfo,area_code,goodsCount){
				console.log('进入',jielongInfo,area_code,goodsCount);
				area_code = area_code.substring(0,2) + '0000';
				console.log('获取运费',jielongInfo,area_code,goodsCount);
				var freightAmount = jielongInfo['info']['freight'] ;
				console.log(freightAmount);
				console.log(jielongInfo);
				//判断是否设置免邮条件
				if (jielongInfo['info']['free_shipping_minimal'] == 0 && jielongInfo['info']['free_shipping_maximum']== 0){
					freightAmount = 0; 
				
				}else if (jielongInfo['info']['free_shipping_minimal'] != 0 || jielongInfo['info']['free_shipping_maximum'] != 0){
					
					if (jielongInfo['info']['free_shipping_maximum'] == 0){
						if (goodsCount >= jielongInfo['info']['free_shipping_minimal']){
							freightAmount = 0;  
						}
					}else if (goodsCount >= jielongInfo['info']['free_shipping_minimal'] && goodsCount < jielongInfo['info']['free_shipping_maximum']){
						freightAmount = 0; 
					}
				}
				//开启偏远地区运费设置
				if (jielongInfo['info']['remote_regions_freight'] == '1'){
					var regionsSettingList = JSON.parse(jielongInfo['info']['remote_regions_freight_setting'],true);
					console.log(regionsSettingList);
					var regionsSetting = '';
					for(var i = 0; i < regionsSettingList.length; i++){
						if(regionsSettingList[i].provinces == area_code){
							regionsSetting = regionsSettingList[i];
							break;
						}
					}
					console.log(regionsSetting);
					//判断是否属于设置区域
					if (regionsSetting){
						//判断 是否是按件计算   1为按商品数量，2为订单 
						if (regionsSetting.billing_method != 1){
							freightAmount +=  Number(regionsSetting['increase_amount']);
						}else{
							freightAmount +=  goodsCount * Number(regionsSetting['increase_amount']);  
						}
	
					}
				}
				// this.sumGoods = this.tui.centsToYuan(Number(this.freightAmount)) + Number(this.sumGoods);
				this.freightAmount = freightAmount;
	// 			return $this->success($freightAmount);
			}
		}
	}
</script>

<style>
	/* 自提点 */
	.bottom_ztd{
		width: 200rpx;
		float: right;
		margin-bottom: 0rpx !important;
		font-size: 26rpx;
		height: 50rpx;
		line-height: 50rpx;
	}
	.top_ztd{
		padding: 20rpx;
		height: 50rpx;
	}
	.list_networkList{
		width: 100%;
		/* border-bottom: 1rpx solid #CFCFCF; */
		height: 290rpx;
		/* background: #FFF; */
		padding-left: 30rpx;
	}
	.list_left{
		width: 15%;
		line-height: 105rpx;
		text-align: center;
		float: left;
	}
	.list_details{
		width: 90%;
		float: left;
		height: 290rpx;
		font-size: 25rpx;
	}
	.list_right{
		width: 10%;
		float: left;
		height: 290rpx;
		line-height: 250rpx;
	}
	.list_tops{
		height: 60rpx;
		line-height: 60rpx;
		margin-top: 24rpx;
	}
	.list_bottom{
		height: 60rpx;
		line-height: 60rpx;
		font-size: 30rpx;
		color: #666;
	}
	.name_networkList{
		float: left;
		width: 290rpx;
		font-size: 28rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		line-clamp: 1;
		-webkit-box-orient: vertical;
		font-size: 36rpx;
		font-weight: 500;
	
	}
	.phone_networkList{
		float: left;
		width: 210rpx;
		font-size: 28rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.title_networkList{
		float: left;
		width: 125rpx;
		/* text-align: center; */
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.address_networkList{
		float: left;
		width: 400rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	/* 自提点 */
	
	page{
		background: #FFFFFF !important;
	}
	.container {
		padding: 20rpx 0 280rpx 0;
	}

	.tui-line-cell {
		width: 100%;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		background: #f7f7f7 !important;
		padding: 25rpx 25rpx !important;
		border-radius: 10rpx;
	}
	

	.tui-title {
		line-height: 30rpx;
		flex-shrink: 0;
		font-weight: 450;
	}

	.tui-input {
		font-size: 30rpx;
		color: #333;
		padding-left: 20rpx;
		flex: 1;
		direction: rtl;
		padding-right: 25rpx;
	}

	.tui-operation {
		z-index: 1001;
		width: 100%;
		height: 100rpx;
		/* box-sizing: border-box; */
		background: rgba(255, 255, 255, 0.98);
		position: fixed;
		display: flex;
		align-items: center;
		justify-content: space-between;
		bottom: 0;
		left: 0;
		padding-bottom: env(safe-area-inset-bottom);
		box-shadow: 0px 0px 15px rgba(0,0,0,0.1);
	}
	
	.red{
		color: red;
	}
	.tui-list-cell.tui-cell-arrow:before {
		right: 55rpx !important;
	}
	.tui-list-cell{
		padding: 8px 16px !important;
	}
	.phcolor{
		text-align: right !important;
		padding-right: 150rpx;
		font-size: 30rpx;
	}

	
	/* 接龙案例 */
	.case_content{
		width: 95%;
		margin: 0px auto;
		border-bottom: 1rpx solid #ededed;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		overflow: hidden;
		padding: 0px 10px  10px 10px;
		margin: 20rpx auto;
	}
	.case_box_des {
		width: 100%;
		/* padding: 10rpx 20rpx; */
		/* padding: 20upx 20upx; */
		margin: 10rpx auto;
		/* border-bottom: 1px solid red; */
	}
	.case_box_left{
		padding-left: 5rpx;
	}
	.case_box_left_title{
		font-size: 30rpx;
		font-weight: 450;
		/* padding: 15rpx 0px; */
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		word-wrap: break-word;
		white-space: normal !important;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.case_box_right{
		font-weight: 500;
		font-size: 35rpx;
		
	}
	.case{
		padding: 0 20rpx 0 20rpx;
	}

	.case_box{
		padding: 0px 18px 10px 18px;
	}

	.tui-header-title{
		font-size: 33rpx !important;
		font-weight: 600;
		margin-top: 10rpx !important;
		color: #000000 !important;
	}

	.tui-card{
		margin: 0rpx !important;
		margin-top: 20rpx !important;
		box-shadow: 0 0 3rpx #eee !important;
		border: 1rpx solid #f5f5f5 !important;
		background: #f7f7f7 !important;
	}
	.tui-card-header{
		background: none !important;
		border-bottom: 1rpx solid #ededed !important;
	}
	.foot_content{
		text-align: right;
		margin: 40rpx auto;
		padding-right: 30rpx;
		font-size: 30rpx;
		color: #000000;
	}
	.price{
		color: red !important;
	}
	.case_box_left_des{
		color: #b4b4b4;
		font-size: 26rpx !important;
	}
	.tui-footer{
		font-size: 26rpx;
		text-align: center;
		color: #888888;
		margin-top: 100rpx;
	}
	.tui-safearea-bottom {
		width: 100%;
		height: env(safe-area-inset-bottom);
	}
	/* 接龙案例 */
	.btn-primary{
		width: 100% !important;
		height: 100% !important; 
		border-radius: 0 !important;
		background: #0A8FE2 !important;

	}

	.tui-list-view {
		padding-top: 30upx !important
	}

	.tui-list-cell-name {
		padding-left: 20upx;
		vertical-align: middle;
		line-height: 30upx;
	}

	.tui-list::after {
		left: 94upx !important
	}

	.tui-land-box {
		display: flex;
		align-items: center;
	}


	.tui-land-item {
		max-width: 600upx;
		min-height: 80upx;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding-left: 10rpx;
	}

	.tui-land-name {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 32upx;
		line-height: 1;
		/* font-weight: 450; */
		color: #262b3a;
	}

	.tui-land-content {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 28upx;
		line-height: 1;
		color: #9397a4;
		padding-top: 5rpx;
	}

	.tui-list-content::after,.tui-list-content::before{
		border-top: none !important;

	}
	.tui-list-cell::after {
		border-bottom: none !important;
	}
	.gps{
		width: 32rpx;
		height: 36rpx;
		display: inline-block;
	}
	
	.tui-modal-title{
		font-size: 34rpx !important;
		font-weight: 450 !important;
	}
	.tui-modal-content{
		font-size: 30rpx !important;
	}
	.tui-red{
		background: #FFFFFF !important;
		color: #0A8FE2 !important;
		font-size: 32rpx !important;
		font-weight: 400 !important;
		padding-top: 10rpx !important;
	}
	.tui-modalBtn-box{
		border-top: 1rpx solid #ebebeb;
	}
</style>
